const Article = require('../model/Article')
const User = require('../model/User')
const Image = require('../model/Image')
async function getBlog(id) {
    let blog = {
        statusCode: 0,
        statusMsg: {}
    }
    let tem = {
        list: Object,
        user: Object
    }
    let article = (await Article.findOne({
        where: {
            id: id
        }
    })).dataValues
    let user = await (await User.findOne({
        where: {
            id: article.userId
        }
    })).dataValues
    let image = await (await Image.findOne({
        where: {
            id: user.portraitId
        }
    })).dataValues
    user.image = image
    tem.list = article
    tem.user = user
    blog.statusMsg = tem
    blog.statusCode = 1
    return blog
}

module.exports = getBlog